home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-09-28 | 2.9 KB | 90 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
-
- import quicktime.app.display.*;
- import quicktime.app.image.*;
- import quicktime.qd.*;
- import quicktime.QTException;
- import quicktime.std.image.Matrix;
- import java.awt.*;
-
- /**
- * This class will present the image that is produced by the given QTImageProducer.
- * If the QTImageProducer is presenting content that has a time or multi-frame element
- * then repaints will be scheduled when the IPDrawer is redrawn.
- * <P>
- * A typical usage of this class is as a client of a QTCanvas that is used within the
- * context of a swing container.
- */
- public class IPDrawer extends ImageDrawer {
- /**
- * Creates an IPDrawer with the given QTImageProducer. The default size of the IPDrawer
- * is the size of the QTImageProducer.
- */
- public IPDrawer (QTImageProducer ip) {
- super (ip.getSize(), null);
- this.ip = ip;
- }
-
- //_________________________ INSTANCE VARIABLES
- private QTImageProducer ip;
-
- //_________________________ INSTANCE METHODS
- /**
- * Returns the QTImageProducer that produces the image for this Drawer
- */
- public QTImageProducer getProducer () { return ip; }
-
- /**
- * This method is called by the specified object when the instance of
- * the class that implements this interface is added to the object
- * that is the source of the interest.
- * @param interest the object that is to be the source of interest for the
- * the object that implements this interface.
- */
- public void addedTo (Object interest) {
- super.addedTo (interest); //this will set the canv variable
- if (canv != null) {
- im = canv.createImage (ip);
- canv.prepareImage (im, canv);
- }
- }
-
- /**
- * This method is called by the specified object when the instance of
- * the class that implements this interface is removed from the object
- * that is the source of the interest.
- * @param interest the object that was the source of interest for the
- * the object that implements this interface.
- */
- public void removedFrom (Object interest) {
- super.removedFrom (interest);
- if (canv == null)
- im = null;
- }
-
- /**
- * QTCanvas calls this method when the client should redraw itself.
- * If the canvas is able to discern that only a part of the client's
- * drawing area needs to be redrawn - then this area shall be passed in
- * using the invalidRgn. Otherwise this will be null in which case the
- * client should redraw itself entirely.
- * @param invalidRgn the invalidRgn that the client should redraw
- */
- public void redraw (Region invalidRgn) throws QTException {
- super.redraw (invalidRgn);
-
- // this redraw should be done in another thread to free up the display thread
- // so that the app is more repsonsive for the user
- // see the sample code
- if (ip.isRedrawing() && canv != null) {
- ip.redraw(invalidRgn);
- }
- }
- }
-